#include <lpc23xx.h>
#include "LCD.h"
int main(void)
{
unsigned int  val = 0x55555555;
    
unsigned int delay; //
	/* Reset all GPIO pins to default: primary function */
    PINSEL0 = 0x00000000;
    PINSEL1 = 0x00000000;
    PINSEL2 = 0x00000000;
    PINSEL3 = 0x00000000;
    PINSEL4 = 0x00000000;
    PINSEL5 = 0x00000000;
    PINSEL6 = 0x00000000;
    PINSEL7 = 0x00000000;
    PINSEL8 = 0x00000000;
    PINSEL9 = 0x00000000;
    PINSEL10 = 0x00000000;
    
    IODIR0 = 0x00000000;
    IODIR1 = 0x00000000;
	  IOSET0 = 0x00000000;
    IOSET1 = 0x00000000;
    
    FIO0DIR = 0x00000000;
    FIO1DIR = 0x00000000;
    FIO2DIR = 0x00000000;
    FIO3DIR = 0x00000000;
    FIO4DIR = 0x00000000;
    
    FIO0SET = 0x00000000;
    FIO1SET = 0x00000000;
    FIO2SET = 0x00000000;
    FIO3SET = 0x00000000;
    FIO4SET = 0x00000000;					
   //vLCDInit();
  //vLCDPutc('T'); 
  // vLCDPuts(Message);
PINSEL0     |= 	    0x5 | 0x2<<8|0x2<<10;
PCONP       |=      0x1<<13 | 0x1<<14;
CAN2MOD 	|= 		0x00000001;			//Set CAN controller into reset
CAN2BTR 	= 	    0x0B | 0x05<<16 | 0x02<< 20;
CAN2MOD 	= 		0x00000000;			//Release CAN controller

    lcd_init();					   //
	lcd_clear();				  //
	set_cursor(1,0);			   // Agaf=/
    lcd_print("CANTx Example");	 //
while(1)
{

CAN2TFI1 		= 		0x00040000;			//Set DLC to 4 bytes 	
CAN2TID1 		= 		0x00000002;			//Set address to 2 Standard Frame


if(CAN2SR & 0x00000004)					//See if Tx Buffer 1 is free
{

CAN2TDA1		=		val;				//Copy A/D result into first four bytes
CAN2CMR 		= 		0x00000021;			//Transmit the message
}
}

}

